package hu.sulirend.model;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

/**
 * Represents a subject at the school.
 *
 * @author <a href="mailto: peter.szilagyi@gmail.com">Peter Szilagyi</a> 
 * @since 2008
 */
@Entity
public class Subject extends BaseEntity {

	private static final long serialVersionUID = -8092477907105025498L;
	
	private String name;
	private Set<Room> possibleRooms;
	
	@Column(unique=true, nullable=false, updatable=true, insertable=true)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@ManyToMany(fetch=FetchType.LAZY, cascade={})
	@JoinTable(name="SUBJECT_ROOM", 
			joinColumns=@JoinColumn(name="SUBJECT_ID", referencedColumnName="id", columnDefinition="INTEGER"),
			inverseJoinColumns=@JoinColumn(name="ROOM_ID", referencedColumnName="id", columnDefinition="INTEGER")
	)
	public Set<Room> getPossibleRooms() {
		return possibleRooms;
	}
	public void setPossibleRooms(Set<Room> possibleRooms) {
		this.possibleRooms = possibleRooms;
	}
	
}
